/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hh;

import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import shenhe.Shpt;

import base.Hezuosj;

/**
 *
 * @author Administrator
 */
//会员信息的鼠标事件

 public class UserMouseAdapter
    extends java.awt.event.MouseAdapter {
   
    private Statement stmt;
 
    private String url;
    private String user;
    private String password;

        public UserMouseAdapter() {
        }

        
         private boolean flag=false;//用来判断是否已经执行双击事件
  private int clickNum=0;//用来判断是否该执行双击事件

private String ss;

  @Override
public void mouseClicked(MouseEvent e) {
      final MouseEvent me=e;//事件源

      this.flag=false;//每次点击鼠标初始化双击事件执行标志为false

      if (this.clickNum == 1) {//当clickNum==1时执行双击事件
        this.mouseDoubleClicked(me);//执行双击事件
        this.clickNum=0;//初始化双击事件执行标志为0
        this.flag=true;//双击事件已执行,事件标志为true
        return;
      }
       
       

       //定义定时器
      java.util.Timer timer=new java.util.Timer();

      //定时器开始执行,延时0.2秒后确定是否执行单击事件
      timer.schedule(new java.util.TimerTask(){
        private int n=0;//记录定时器执行次数
        @Override
		public void run() {
          if(flag){//如果双击事件已经执行,那么直接取消单击执行
            n=0;
            clickNum=0;
            this.cancel();
            return;
          }
          if (n == 1) {//定时器等待0.2秒后,双击事件仍未发生,执行单击事件


            mouseSingleClicked(me);//执行单击事件
            flag = true;
            clickNum=0;
            n=0;
            this.cancel();
            return;
          }
          clickNum++;
          n++;
        }
      },new java.util.Date(),300); // 设置延迟时间
    }
        
         public void mouseSingleClicked(MouseEvent e){
     System.out.println("Single Clicked!");
    } 

    /** *//**
     * 鼠标双击事件
     * @param e 事件源参数
     */
    public void mouseDoubleClicked(MouseEvent e){
     System.out.println("Doublc Clicked!");
       
    }


    
    public void showClick(Object o) {
      
    		String s=o.toString();
      
    
 try
  {
	 new Hyzl();
 Connection con=DriverManager.getConnection(beans.getUrl(),beans.getUser(),beans.getPassword());
  if(!con.isClosed())
  System.out.println("打开数据库成功"+s);
 
  
  //根据名字来查询资料
  
  stmt = con.createStatement();
  String searchnameu="SELECT * FROM hhzc.hzsj where sjname='"+s+"';";
   ResultSet rsuser=stmt.executeQuery(searchnameu);
    while (rsuser.next()) {
           
//System.out.println( rsuser.getCursorName());
    	Hyzl.cname.setText(rsuser.getObject(3).toString());
    	Hyzl.csex.setText(rsuser.getObject(4).toString());
    	Hyzl.cxl.setText(rsuser.getObject(5).toString());
    	Hyzl.csfz.setText(rsuser.getObject(6).toString());
    	Hyzl.cphone.setText(rsuser.getObject(7).toString());
    	Hyzl.chj.setText(rsuser.getObject(8).toString());
    	Hyzl.cxjzd.setText(rsuser.getObject(9).toString());///
    	Hyzl.cdh.setText(rsuser.getObject(10).toString());
    	Hyzl.cdw.setText(rsuser.getObject(11).toString());
    	Hyzl.cdwdh.setText(rsuser.getObject(12).toString());
    	Hyzl.cdwdz.setText(rsuser.getObject(13).toString());
    	Hyzl.khjl.setText(rsuser.getObject(42).toString());
 
 }
    
  stmt.close();
  con.close();
 
  }
   catch(Exception e){
            System.out.print("Error occurred in inserting data");
            e.printStackTrace();
        }
    }

    public void showsjClick(Object o) {
        
		String s=o.toString();
  

try
{
 new Hezuosj();
Connection con=DriverManager.getConnection(beans.getUrl(),beans.getUser(),beans.getPassword());
if(!con.isClosed())
System.out.println("打开数据库成功"+s);


//根据名字来查询资料

stmt = con.createStatement();
String searchnameu="SELECT * FROM hhzc.hzsj where sjname='"+s+"';";
ResultSet rsuser=stmt.executeQuery(searchnameu);
while (rsuser.next()) {
       
//System.out.println( rsuser.getCursorName());
	Hezuosj.textField.setText(rsuser.getObject(3).toString());
	Hezuosj.textField_1.setText(rsuser.getObject(4).toString());
	Hezuosj.textField_2.setText(rsuser.getObject(5).toString());
	Hezuosj.textField_3.setText(rsuser.getObject(6).toString());
	Hezuosj.textField_4.setText(rsuser.getObject(7).toString());
	Hezuosj.textField_5.setText(rsuser.getObject(8).toString());
	Hezuosj.textField_6.setText(rsuser.getObject(9).toString());///
	Hezuosj.textField_7.setText(rsuser.getObject(10).toString());///
	Hezuosj.textField_8.setText(rsuser.getObject(11).toString());///

}

stmt.close();
con.close();

}
catch(Exception e){
        System.out.print("Error occurred in inserting data");
        e.printStackTrace();
    }
}
    //审核通过
public void showshtg(Object o) {
        
		String s=o.toString();
  

		
try
{
 new Shpt();
 
Connection con=DriverManager.getConnection(beans.getUrl(),beans.getUser(),beans.getPassword());
if(!con.isClosed())
System.out.println("打开数据库成功"+s);


//根据名字来查询资料

stmt = con.createStatement();
String SQLd = "select sqr.cname,sqr.sqdh,sqr.cphone,sqr.csfz,dksh.htbh,dksh.fkjr,dksh.jubh,dksh.qdrq,dksh.fkrq,dksh.jcrq, sqr.uid  " +
		"from  hhzc.sqr, hhzc.dksh where sqr.uid = dksh.uid and dksh.htbh='"+s+"';";
ResultSet rsuser=stmt.executeQuery(SQLd);
while (rsuser.next()) {
       
//System.out.println( rsuser.getCursorName());
	Shpt.textField.setText(rsuser.getObject(1).toString());
	Shpt.textField_1.setText(rsuser.getObject(2).toString());
	Shpt.textField_2.setText(rsuser.getObject(3).toString());
	Shpt.textField_3.setText(rsuser.getObject(4).toString());
	Shpt.textField_4.setText(rsuser.getObject(5).toString());
	Shpt.textField_6.setText(rsuser.getObject(6).toString());
	Shpt.textField_7.setText(rsuser.getObject(7).toString());
	Shpt.textField_8.setText(rsuser.getObject(8).toString());///
	Shpt.textField_10.setText(rsuser.getObject(9).toString());///
	Shpt.textField_11.setText(rsuser.getObject(10).toString());///
     ss=rsuser.getObject(11).toString();
}
Shpt.showdata(ss); 
stmt.close();
con.close();

}
catch(Exception e){
        System.out.print("Error occurred in inserting data");
        e.printStackTrace();
    }
}
    }
